package lab03.test11;

import java.sql.*;

public class Test11 {
    public static void main(String[] args) {
        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;

        String sql1="create database java_2017";

        String  sql2="create table t_users("+
                "id int primary key,"+
                "username varchar(100) not null,"+
                "password varchar(100) not null ,"+
                "register long not null"+
                ")";
        String sql3="insert into t_users"+
                "select 1,'admin',192312312123 union"+
                "select 2,'chen','123456' ,123123123123";

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC&characterEncoding=utf-8","root","123456");
            statement=connection.createStatement();
            statement.execute(sql3);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                connection.close();
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }

    }
}
